package cn.itcast.day04;

import java.util.Scanner;

//键盘输入一个字符串，并且统计其中各种字符出现的次数
//种类有：大写字母，小写字母，数字，特殊符号
public class text02 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String input = sc.next();//获取键盘输入的一个字符串

        int countUpper = 0;
        int countLower = 0;
        int countNumber = 0;
        int countSpecialCharacter = 0;

        //对字符串字字检查，String-->char[]，方法就是toCharArray()
        char[] charArray = input.toCharArray();

        for (int i = 0; i < charArray.length; i++) {
            char ch = charArray[i];
            if (ch >= 'A' && ch <= 'Z') {
                countUpper++;
            }else if (ch >= 'a' && ch <= 'z') {
                countLower++;
            }else if (ch >= '0' && ch <= '9') {
                countNumber++;
            }else {
                countSpecialCharacter++;
            }
        }
        System.out.println("大写字母有" + countUpper + "个");
        System.out.println("小写字母有" + countLower + "个");
        System.out.println("数字有" + countNumber + "个");
        System.out.println("特殊字符有" + countSpecialCharacter + "个");
    }
}
